﻿using System;

namespace Middleware
{
    [Serializable]
    public abstract class StubBase
    {
        private IOR _ior;

        public StubBase(RemoteObject remoteObject) {
            this._ior = new IOR(remoteObject.ObjectID, remoteObject.IP, remoteObject.Port);
        }

        protected object Execute(string methodName, bool hasReturnValue, params object[] parameters) {
            MessageReply message = Requestor.Request(_ior, methodName, hasReturnValue, parameters);
            if (message.IsError) {
                throw new Exception(message.ErrorMessage);
            }
            return message.ReturnValue;
        }
    }
}
